package templ

import (
	"html/template"
	"log"
	"os"
)

type Data struct {
	Name  string
	Num   int
	Notes []string
	Mp    map[string]string
}

func runTempl() {

	tmpl, err := template.ParseFiles("./code.tmpl")
	if nil != err {
		log.Fatalf("%v", err)
	}

	notes := []string{"一", "二", "三", "四"}
	mp := make(map[string]string, 10)
	mp["1"] = "答复"
	mp["2"] = "反射"
	mp["3"] = "水电费"
	mp["4"] = "非凡哥"
	data := &Data{
		Name:  "模板",
		Num:   56,
		Notes: notes,
		Mp:    mp,
	}

	err = tmpl.Execute(os.Stdout, data)
	if nil != err {
		log.Fatalf("%v", err)
	}

}
